#pragma once
#include "dll_export.h"
#include "DebugEvent.h"
#include "Mediator.h"
#include "../cppx.luavm/sysinfo.h"
#include <wx/aui/auibook.h>

LUA_DEBUG_BEGIN

class SourceViewPage;

class SourceView : public wxAuiNotebook
{
    DECLARE_EVENT_TABLE();

    Mediator_ptr m_mediator;

public:
    //SourceView(wxWindow *parent);
    SourceView(wxWindow* parent,
        wxWindowID id = wxID_ANY,
        const wxPoint& pos = wxDefaultPosition,
        const wxSize& size = wxDefaultSize,
        long style = wxAUI_NB_DEFAULT_STYLE);
    virtual ~SourceView();

    void SetMediator(Mediator_ptr mediator){ m_mediator = mediator; }
    void ToggleBreakpoint();
    void CreatePage(const Source &source);

private:
    //void CreateGUIControls();
    size_t FindPageFromKey(const std::string &key);
    SourceViewPage *GetPage(size_t i);
    SourceViewPage *GetSelected();

private:
    void OnEndDebug(wxDebugEvent &event);
    void OnChangedState(wxDebugEvent &event);
    void OnUpdateSource(wxDebugEvent &event);
    void OnAddedSource(wxDebugEvent &event);
    void OnFocusErrorLine(wxDebugEvent &event);
    void OnFocusBacktraceLine(wxDebugEvent &event);
};

LUA_DEBUG_END
